-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Demonstrate nested ifs (bis) #4
Demonstrate nested ifs (bis) #4
Conversation
Spells out the situation with nested `if`s to better demonstrate why `cond` is useful. Would be better with an example that needs yet more control paths (to demonstrate scalability of `cond`).
This follows the same pattern used to introduce `if`: start with an example and explanation, show the general form, then show a more elaborate example.
Looks great. Perhaps we should go a step further and replace the first example with the one you've prepared for the last example (i.e. adding a corresponding nested |
Yeah that might be a good idea. We are looking at it now as well, this if example is also what is used to introduce |
👍 |
Looks good to me! |
Hold off on it a little longer, I'm making more changes to the control flow chapter to remove references to the turtle thing |
What about starting with: |
I thought it made more sense this way because "th" is the general case (the |
Yeah I know what you mean. At that point though, they've not seen I don't suppose it'll make much difference either way. |
Yeah I can see your point as well, it might help to drive home the point that the "else" branch is not equivalent to the "if" branch though, since it's really more of a catch-all/fallback. Many people won't be familiar with the word "ordinal". It's introduced straight away with some examples so it should be reasonably clear from context, and the coach can clarify. Would that be good enough, or should we add an extra paragraph to introduce the "ordinal" concept? The second version of |
I think ordinal is easy enough to explain - you might add a "Details" link though. It's not as mathsy as modulo etc. Dealing with 102nd etc is a good exercise but that will require people to use modulo! At least that's how I'd solve it..? |
You would need modulo, yeah, and an exception for 11th, 12th, 13th. This how Ruby on Rails implements it
I would rather not point that out though, I don't think people should go that deep on this one exercise. |
Ah yeah. Good point. Maybe that's better swept under the carpet for now! |
@Robsteranium what do you think of this? I started from your branch (#2) but split the
cond
code example up, and added an extra example. This way it follows the pattern that you also used forif
, introduce, general form, more elaborate example.Before:
After: